package org.algorithm.biubiu.wheel_1.字符串;

import org.junit.Test;

/**
 * @author jiazhaoxin
 * @Date 2022/2/28
 * @Desc {https://leetcode-cn.com/problems/reverse-words-in-a-string/}
 */
public class 翻转字符串里的单词 {



    @Test
    public void test(){
    }

    public String reverseWords(String s) {
        String[] data = s.split(" ");
        StringBuilder sb  = new StringBuilder();
        for(int i = data.length-1; i>=0;i--){
            if(!data[i].trim().equals("")){
                sb.append(data[i]).append(" ");
            }

        }
        return  sb.toString().trim();
    }
}
